Socket
Socket
Sign inDemoInstall

unified-lint-rule

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unified-lint-rule

unified plugin to make it a bit easier to create linting rules


Version published
Maintainers
2
Created

What is unified-lint-rule?

The `unified-lint-rule` package is a utility for creating linting rules for unified processors. Unified is a project that provides a suite of tools for processing content, such as Markdown and HTML, in a structured way. The `unified-lint-rule` package allows developers to define custom linting rules that can be used to enforce coding standards, catch errors, and ensure consistency in content processing.

What are unified-lint-rule's main functionalities?

Creating a Custom Lint Rule

This feature allows you to create a custom linting rule. In this example, the rule checks for the presence of the word 'foo' in text nodes and reports a message if it is found.

const rule = require('unified-lint-rule');
const visit = require('unist-util-visit');

const noFoo = rule('example/no-foo', (tree, file) => {
  visit(tree, 'text', (node) => {
    if (node.value.includes('foo')) {
      file.message('Do not use the word "foo"', node);
    }
  });
});

module.exports = noFoo;

Integrating with Unified Processor

This feature demonstrates how to integrate a custom linting rule with a unified processor. The example shows how to use the `unified`, `remark-parse`, and `remark-lint` packages along with the custom `noFoo` rule to process a Markdown string and report any linting messages.

const unified = require('unified');
const markdown = require('remark-parse');
const lint = require('remark-lint');
const noFoo = require('./path-to-no-foo-rule');

unified()
  .use(markdown)
  .use(lint)
  .use(noFoo)
  .process('This is a foo test', (err, file) => {
    if (err) throw err;
    console.error(report(file));
  });

Other packages similar to unified-lint-rule

Keywords

FAQs

Package last updated on 16 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc